package com.cs171.market.mapper;

import com.cs171.market.entity.CartList;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CartListMapper {
    @Select("select id,g.gname,g.gimg,norm,g.gprice,quant from cartlist c,good g where c.uid=#{id} and c.gid=g.gid")
    List<CartList> getCartListByGid(Integer id);

    @Select("update cartList set quant=quant+1,uid=#{uid} where id=#{id}")
    void add(Integer uid,Integer id);

    @Select("update cartList set quant=quant-1 where id=#{id}")
    void minus(Integer id);

    @Select("delete from cartList where id=#{id}")
    void delete(Integer id);

    @Select("update cartList set quant=#{value} where id=#{id}")
    void change(Integer id,Integer value);

    @Select(("select quant from cartList whew id=#{id}"))
    void getQuant(Integer id);

    @Select("insert into cartList(id,quant,norm,uid,gid)values(#{id},1,#{norm},#{uid},18)")
    void addItem(Integer uid,Integer id,String norm);
}
